package com.contact;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

public class ListContactAdapter extends ArrayAdapter<Info> {
	Context context;
	int resource;
	ArrayList<Info> array;

	public ListContactAdapter(Context context, int textViewResourceId,
			ArrayList<Info> objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
		this.array = objects;
		this.context = context;
		this.resource = textViewResourceId;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view = convertView;
		if (view == null) {
			view = new ListContactView(getContext());
		}
		final Info user = array.get(position);
		if (user != null) {
			

		}
		return view;
	}

	/**
	 * 
	 * @param view
	 * @param path
	 */
	public void setAvatar(ImageView view, String path) {
		try {
			if (path != null) {
				FileInputStream file = new FileInputStream(path);
				BufferedInputStream buf = new BufferedInputStream(file);
				Bitmap bit = BitmapFactory.decodeStream(buf);
				view.setImageBitmap(bit);
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
